#ifndef GROUP_H
#define GROUP_H

#include <QDialog>
#include <QTextEdit>
#include <QQueue>
#include <QCheckBox>
#include <QRadioButton>

QT_BEGIN_NAMESPACE
class QComboBox;
class QDialogButtonBox;
class QGridLayout;
class QGroupBox;
class QLabel;
class QPushButton;
class QSpinBox;
class QLineEdit;
class QTabWidget;
class Register;
QT_END_NAMESPACE

/** Class that represents a group of bits, or field, that is contained in a register and is displayed as a tab in a TabWidget.*/
class Group : public QWidget
{
    Q_OBJECT

public slots:
    void changeTabName(QString str);
    void upperBitChanged(int i);
    void lowerBitChanged(int i);
    void hasChanged();
    void readHasChanged();

public:
    Group(int i, Register *r);

    QLineEdit* getGroupName(){return groupName;};
    QCheckBox* getInterrupt(){return interrupt;};
    QSpinBox* getBitsNumber(){return bitsNumber;};
    QSpinBox* getUpperBit(){return upperBit;};
    QSpinBox* getLowerBit(){return lowerBit;};

    void setOffset(int i){offset=i;};
    int getOffset(){return offset;};
    QLabel* getOffsetLabel(){return offsetLabel;};
    int getId(){return id;};
    QTextEdit* getDescription(){return description;};
    bool isReadOnly(){return readOnly->isChecked();};
    void setRW(){readWrite->setChecked(true);};
    void setIRQ(){interrupt->setChecked(true);};
    void switchNotation(Qt::LayoutDirection dir);
private:
    QGridLayout *inLayout;
    QLineEdit *groupName;
    QCheckBox *interrupt;

    QSpinBox *bitsNumber;
    QSpinBox *lowerBit;
    QSpinBox *upperBit;

    //! Pointer to the parent register
    Register *reg;
    QLabel *nameLabel;
    QLabel *idLabel;
    QLabel *offsetLabel;
    QLabel *ubLabel;
    QLabel *lbLabel;

    int id;
    int offset;
    int fieldBits;

    QTextEdit *description;
    QLabel *descrLabel;
    QRadioButton* readOnly;
    QRadioButton* readWrite;

};


#endif // GROUP_H
